BASE:=$(shell pwd | xargs basename)
CPPFLAGS = -I. -I../../3rd/antlr/include -I../../3rd/libantlr3c-3.2 -I../../include
CPPSOURCES=${wildcard *.cpp}
VERSION=?-g


EXTENSION=
ifeq ($(VERSION),-g)
EXTENSION=-g
endif

OBJECTS=$(patsubst %.cpp,%$(EXTENSION).o,$(CPPSOURCES))

ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
-include $(SOURCE_DEPENDENCIES)
endif


../../lib/lib$(BASE)$(EXTENSION).a: $(OBJECTS)
	ar rcs $@ $(OBJECTS)
	rm $<

%$(EXTENSION).o:%.cpp
	ag++ -c $(CPPFLAGS) $(EXTENSION) $< -o $@
	cp $@ ../../.objs

echo:
	@echo $(OBJECTS)
	@echo $(CPPSOURCES)

clean:
	rm -f *.o *.d
